package day230403;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/4/5 0:26
 * 幸运的袋子
 */
public class Main02 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt(); // 球的个数
        int[] number = new int[n]; // 球的号码
        for (int i = 0; i < number.length; i++) {
            number[i] = scan.nextInt();
        }
        // 先排序
        Arrays.sort(number);
        int res = dfs(number, n, 0, 0, 1);
        System.out.println(res);
        scan.close();
    }

    private static int dfs(int[] number, int n, int pos, int sum, int multiple) {
        int res = 0; // 记录幸运袋子数
        for (int i = pos; i < n; i++) {
            sum += number[i];
            multiple *= number[i];
            if (sum > multiple) {
                res += 1 + dfs(number, n, i+1, sum, multiple);
            } else if (number[i] == 1) {
                // 1 + 1 + ... + 1 > 1 * ... * 1
                res += dfs(number, n, i+1, sum, multiple);
            } else {
                break; // num 排序, 后面的不需要继续判断
            }
            // 回退
            multiple /= number[i];
            sum -= number[i];
            // 避免重复
            while (i < n - 1 && number[i] == number[i+1]) {
                i++;
            }
        }
        return res;
    }
}
